import { Map } from "immutable"; // 深拷贝state 
import * as actionTypes from "../types/award";

const initialState = Map({
  allList: {},
  awardcenter:[],
  awarddetail:{},
  pageNo:{}
})

export default function reducer(state = initialState, action) {
    switch (action.type) {
      case actionTypes.REQUEST_AWARD_CENTER :
        state = state.set("awardcenter",action.data.datas)
        break;
      
      case actionTypes.REQUEST_AWARD_DETAIL :
        let type = action.data.type;
        let temp = state.get("awarddetail")
        temp[type] =  temp[type] || []
        if(action.data.pageNo == 1){
          temp[type] = action.data.data.datas.list
        }else{
          temp[type] = temp[type].concat(action.data.data.datas.list) 
        }
        state = state.set("awarddetail",temp)
        // let temp2 = state.get("pageNo")
        // temp2[type]= action.data.data.datas.pageNo
        // state = state.set("pageNo",temp2)
        console.log("reduer detail changer");
        return state;

    }
    return state
}